import axios from "axios";
import { Message } from "element-ui";
// 创建副本
const _axios = axios.create({
  baseURL: process.env.VUE_APP_URL,
});
// 请求拦截
_axios.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);
// 响应拦截
_axios.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    if (error.response.data && error.response.data.message) {
      Message.error(error.response.data.message);
    }
    return Promise.reject(error);
  }
);

export default _axios;
